<template>
  <div class="milk-article">
    <a href="javascript:void(0)" @click="readMore"
       class="milk-article-img"
       :style="{backgroundImage: value.cover?`url(${value.cover})`:`url(/image/article/demo-p1.jpg)`}"
       ></a>
    <div class="milk-article-body">
      <h4 class="article-heading"><a href="javascript:void(0)" @click="readMore">{{ value.title }}</a></h4>
      <div class="article-meta">
        <a href="javascript:void(0)"><span
            class="iconfont  icon-time"></span><span>{{
            value.createTime.split('.')[0].split('T').join(' ')
          }}</span></a>
        <a href="javascript:void(0)"><span class="iconfont  icon-mine"></span><span>{{ value.author }}</span></a>
        <a href="javascript:void(0)"><span
            class="iconfont  icon-message"></span><span>{{
            value.numberOfComment ? value.numberOfComment : 0
          }}</span></a>
      </div>
      <div class="article-preview">
        {{ value.description }}
      </div>
      <div class="article-more">
        <a href="javascript:void(0)" @click="readMore" class="article-link">阅读全文</a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ArticleCard',
  props: {
    value: Object
  },
  methods: {
    readMore () {
      this.$router.push({
        path: 'article/' + this.value._id
      })
    }
  }
}
</script>

<style src="assets/css/article.css"></style>
<style>
.milk-article {
  display: flex;
  width: 100%;
  padding: 16px 24px;
  margin-bottom: 40px;
  border-radius: 16px;
  box-shadow: 0 0 2rem 0 rgba(136, 152, 170, .15);
  border:1px solid #e9e9f2;
  background-color: #FFFFFF;
}

.milk-article:hover{
  border-color: rgba(118,109,244,0.35);
}

.milk-article-img {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  margin-right: 24px;
  background-size: cover;
}

.article-heading > a {
  color: #505050
}

.article-preview {
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  padding: 14px 4px;
  text-align: left;
  color: #515151;
}

.milk-article .iconfont {
  margin-right: 1px;
  font-size: 14px;
}

.article-more {
  margin-top: 20px;
  overflow: hidden;
}

.article-link {
  display: inline-block;
  padding: 6px 24px;
  color: #FFFFFF;
  float: right;
  /*color: #0f6a6d;*/
  border-radius: 4px;
  background-color: #ff9a2e;
}

.article-link:hover {
  background-color: #ffc17f;
}

@media (max-width: 768px) {
  .milk-article {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .milk-article-img {
    margin-bottom: 14px;
  }
}
</style>
